import {WeaEchart} from 'ecCom'

class EcontentItem extends React.Component {

  componentDidUpdate() {
    const { origin } = this.props;
    if(origin == 'returnedChart') {
      this.refs.returnedChart && this.refs.returnedChart.clear();
      this.refs.returnedChart && this.refs.returnedChart.paint();
    }
  }

  chartAction = (chart) => {
    const { onChartClick } = this.props;
    chart.off("click");
    chart.on('click', (params) => {
      onChartClick(params);
    });

  }

  render() {
    const { style,option,origin } = this.props;
    return ( 
      <div className='echart-item'>
          <WeaEchart ecId={`${this && this.props && this.props.ecId || ''}_WeaEchart@ba3zqd`} 
            style={style}
            ref={origin} 
            option={option} 
            useDefault={false} 
            chartAction={this.chartAction}
          />
      </div>
    ) 
  }
}
export default EcontentItem;


